# this version of getCSPPattern represents a experimental version
# of pattern detection. Marubozu Special

getCSPPattern4 <- function(TS, from="1992", to=NULL) {
  if (!is.xts(TS)) {
    stop("TS argument supplied to getCSPPattern is not a xts object")
  }
  Marubozu <- CSPMarubozu(TS)
  Marubozu_1_2 <- CSPMarubozu(TS, maxuppershadowCL=.2, maxlowershadowCL=.2)
  colnames(Marubozu_1_2) <- c("WM_1_2", "BM_1_2")
  Marubozu_1_3 <- CSPMarubozu(TS, maxuppershadowCL=.3, maxlowershadowCL=.3) 
  colnames(Marubozu_1_3) <- c("WM_1_3", "BM_1_3")
  Marubozu_1_4 <- CSPMarubozu(TS, maxuppershadowCL=.4, maxlowershadowCL=.4)
  colnames(Marubozu_1_4) <- c("WM_1_4", "BM_1_4")
  Marubozu_2_2 <- CSPMarubozu(TS, ATRFactor=1.2, maxuppershadowCL=.2, maxlowershadowCL=.2)
  colnames(Marubozu_2_2) <- c("WM_2_2", "BM_2_2")
  Marubozu_2_3 <- CSPMarubozu(TS, ATRFactor=1.2, maxuppershadowCL=.3, maxlowershadowCL=.3)
  colnames(Marubozu_2_3) <- c("WM_2_3", "BM_2_3")
  Marubozu_2_4 <- CSPMarubozu(TS, ATRFactor=1.2, maxuppershadowCL=.4, maxlowershadowCL=.4)
  colnames(Marubozu_2_4) <- c("WM_2_4", "BM_2_4")
  
  if (is.null(to)) {
    subsetstring = paste(from, "/", sep="")
  } else {
    subsetstring = paste(from, to, sep="/")
  }
  result <- cbind(
    Marubozu,
    Marubozu_1_2,
    Marubozu_1_3,
    Marubozu_1_4,
    Marubozu_2_2,
    Marubozu_2_3,
    Marubozu_2_4
    )
  return (result[subsetstring])
}
